<?php

$con = mysql_connect("localhost","root","123") or die  ('Error connecting to mysql');
mysql_select_db("tradiemthi");
@mysql_query("SET NAMES 'UTF8'");

 
require_once dirname(__FILE__)."/application/third_party/PHPExcel.php";
require_once dirname(__FILE__).'/application/third_party/PHPExcel/IOFactory.php';

trans_data();
mysql_close($con);

function trans_data(){
	$start_time = time();
	ini_set('memory_limit', '5000M');

	$file = dirname(__FILE__).'/dataupload/LDA.xlsx';
	$inputFileType = PHPExcel_IOFactory::identify($file);

	$objReader = PHPExcel_IOFactory::createReader($inputFileType);
	$objPHPExcel = $objReader->load($file);
	$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);

	$arr_insert = array();
	unset($sheetData[1]);
	$i = 1;
	foreach ($sheetData as $data) {
		echo "\r".$i;
		$i++;
		$arr_insert['NV_MA_TRUONG'] = $data['A'];
		$arr_insert['NV_MA_NGANH'] = '';
		$arr_insert['NV_TEN_NGANH'] = '';
		$arr_insert['NV_KHOI_THI'] = $data['B'];
		$arr_insert['NV_HO_TEN'] = $data['C'];
		$arr_insert['NV_KHUVUC'] = $data['E'];
		$arr_insert['NV_SO_BAODANH'] = $data['F'];
		$arr_insert['NV_DIEM1'] = @$data['G']/100;
		$arr_insert['NV_DIEM2'] = @$data['H']/100;
		$arr_insert['NV_DIEM3'] = @$data['I']/100;
		$arr_insert['NV_TONG'] = @$data['J']/100;
		mysql_query("insert into `nv1`  (NV_MA_TRUONG,NV_MA_NGANH,NV_TEN_NGANH,NV_KHOI_THI,NV_HO_TEN,NV_KHUVUC,NV_SO_BAODANH,NV_DIEM1,NV_DIEM2,NV_DIEM3,NV_TONG) values ('".$arr_insert['NV_MA_TRUONG']."', '".$arr_insert['NV_MA_NGANH']."', '".$arr_insert['NV_TEN_NGANH']."', '".$arr_insert['NV_KHOI_THI']."', '".$arr_insert['NV_HO_TEN']."', '".$arr_insert['NV_KHUVUC']."', '".$arr_insert['NV_SO_BAODANH']."', '".$arr_insert['NV_DIEM1']."', '".$arr_insert['NV_DIEM2']."', '".$arr_insert['NV_DIEM3']."', '".$arr_insert['NV_TONG']."')");
	}
	$end = time() - $start_time;
	echo "Time: ".$end." s";

}






?>